//
//  OrderlistViewController.m
//  car
//
//  Created by chenxu on 15/3/21.
//  Copyright (c) 2015年 chenxu. All rights reserved.
//

#import "OrderlistViewController.h"
#import "ConversationViewController.h"
#import "FinishedOrderViewController.h"
@interface OrderlistViewController ()

@end

@implementation OrderlistViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    _orderlist = [[OrderListView alloc]initWithFrame:CGRectMake(0, 0, kScreen_Width, self.view.frame.size.height-64) Orders:nil selectblock:^(Order *order) {
        if (_finished == false) {
            [self performSegueWithIdentifier:@"conversation" sender:order];
        }
        else{
            [self performSegueWithIdentifier:@"2finished" sender:order];
        }
        
    } Finished:_finished
        who:user];
    
    [self.view addSubview:_orderlist];
    
    if (_finished) {
        self.title = @"已完成订单";
    }
    else{
        self.title = @"未完成订单";
    }
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [_orderlist refreshUI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    if ([segue.identifier isEqualToString:@"conversation"]) {
        ConversationViewController *vc = segue.destinationViewController;
        vc.myOrder = (Order*)sender;
    }
    if ([segue.identifier isEqualToString:@"2finished"]) {
        FinishedOrderViewController *vc = segue.destinationViewController;
        vc.myOrder = (Order*)sender;
    }
}


@end
